<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-show的使用</title>
  <style>
    .img {
      width: 300px;  
      height: 300px;  
      background-color: aquamarine;  
      display: flex; /* 使用弹性盒子布局 */  
      justify-content: center; /* 水平居中 */  
      align-items: center; /* 垂直居中 */
    }
    .img2 {
      position: absolute; /* 绝对定位 */  
      top: 50%; /* 距离顶部50% */  
      left: 50%; /* 距离左边50% */  
      transform: translate(-50%, -50%); /* 将自己的中心点移到父元素中心 */ 
    }
  </style>
</head>
<body>
  <!--模版语法-->
  <div id="app">
    <div @click="toggle">
      <button>切换</button>
    </div>
    <div class="img" v-show="isShowQRCode">
      <img src="https://img1.baidu.com/it/u=16287752,2019165622&fm=253&fmt=auto&app=138&f=JPEG?w=266&h=266">
      <span style="color: red;">v-show</span>
    </div>
    <br>
    <div class="img" v-if="isShowQRCode">
      <img src="https://img1.baidu.com/it/u=16287752,2019165622&fm=253&fmt=auto&app=138&f=JPEG?w=266&h=266">
      <span style="color: red;">v-if</span>
    </div>
  </div>
  <script src="../lib/vue.js"></script>
  <script>
    // 使用vue
    const app = Vue.createApp({
      data: function(){
        return {
          isShowQRCode: true 
        }
      }
      ,methods: {
        toggle() {
          this.isShowQRCode = !this.isShowQRCode
        }
      }
    }
    )
    // 挂载 
    app.mount("#app")

  </script>

</body>
</html>
